package com.smile.f315;
import java.awt.Color;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Ellipse2D;
import javax.swing.JFrame;
import javax.swing.JPanel;
class ColorPanel extends JPanel{
	public void paintComponent(Graphics g){
		super.paintComponents(g);
		Graphics2D g2 = (Graphics2D)g;
		GradientPaint redToWhite = new GradientPaint(0, 0, Color.RED, 150, 0, Color.WHITE);
		g2.setPaint(redToWhite);
		Ellipse2D ellipse = new Ellipse2D.Double(50, 10, 150, 60);
		g2.fill(ellipse);
	}
}
public class ColorDemo {
	public void createUI(){
		JFrame frame = new JFrame("绘制矩形示例程序");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
		ColorPanel panel = new ColorPanel();
		frame.add(panel);
		
		frame.setBounds(200, 200, 250, 120);
		frame.setVisible(true);
	}
	public static void main(String[] args) {
		ColorDemo example = new ColorDemo();
		example.createUI();
	}
}